package org.webequa.core.maple.quantity;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.webequa.core.common.quantity.RealNumber;
import org.webequa.core.generic.signature.GenericQuantityObjectSignature;


import com.maplesoft.externalcall.MapleException;


public class MapleRealNumber extends MapleQuantityObject implements RealNumber
{
	public MapleRealNumber()
	{
		super();
		signature = GenericQuantityObjectSignature.getRealNumberSignature();
		try
		{
			mapleObject = mapleEngine.newName(mapleVarName, true);
			mapleObject.assign(mapleEngine.newNumeric(0.0));
		} catch (MapleException e)
		{
			log.error("Constructor",e);
			mapleObject = null;
		}
	}
	
	public MapleRealNumber(double in)
	{
		super();
		signature = GenericQuantityObjectSignature.getRealNumberSignature();
		try
		{
			mapleObject = mapleEngine.newName(mapleVarName, true);
			mapleObject.assign(mapleEngine.newNumeric(in));
		} catch (MapleException e)
		{
			log.error("Constructor",e);
			mapleObject = null;
		}		
	}
	
	@Override
	public Double getValue()
	{
    if (mapleObject==null)
      return null;
    else try
    {
      return mapleObject.evalhf();
    } catch (MapleException e)
    {
      log.error("Get value",e);
      return null;
    }
	}
	private static final Logger log = LoggerFactory.getLogger(MapleRealNumber.class);
	@Override
	public void setValue(double arg0) {
		// TODO Auto-generated method stub
		
	}
}
